﻿<?php
define('o', 0); //声明可以访问 
// 载入初始化且必须在任何输出之前包括HTML标签
require_once('./include/initialize.php');
    if (empty($_GET['id'])) {
        header('Location:../');
        die;
    }else{
        if(!is_integer((integer)$_GET['id'])){
            $_GET['id'] = 1;
            $goods_id = $_GET['id'];
        }else{
            $goods_id = $_GET['id'];
        }
        if($goods_id<1){
            $goods_id = 1;
        }
        $file = ROOT . '/temp/goods/' . $goods_id . '.html';
        if(is_file($file)){
            if (time() > filemtime($file) + config::create()->page['staticcontinue']){
                unlink($file);
            }
        }
        
        if (!empty($_SERVER['HTTP_REFERER'])) {
            setcookie("src",$_SERVER['HTTP_REFERER']);
        }else{
            setcookie("src",$_SERVER['REQUEST_URI']);
        }

        if(is_file($file)){
            ob_start();
            echo file_get_contents($file);
            ob_end_flush();
            die;
        }

        $sql = "SELECT goods.goods_id AS goods_id , goods.goods_name AS goods_name , goods.goods_image AS goods_image , class1.class_name AS g_type , class2.class_name AS g_class ,type_name,message.message_val AS message_val FROM xxx_goods AS goods LEFT JOIN xxx_class AS class1 ON goods.goods_type = class1.class_id LEFT JOIN xxx_class AS class2 ON goods.goods_class = class2.class_id LEFT JOIN xxx_type AS type ON goods_keymodel = type_father_id LEFT JOIN  xxx_message AS message ON message.goods_id = goods.goods_id AND message.type_id = type.type_id WHERE goods.goods_id = $goods_id";
        $model = new model("xxx_goods");
        $temp = $model->query($sql, array('goods_id', 'goods_name',"goods_image", 'g_type', 'g_class' ,'type_name','message_val'), $count);
        // $temp['count'] = $count;
        $model->close();
        if (count($temp)<=1) {
            $error = "抱歉哦！没有找到你要的页面 404";
            include(ROOT . "/error.php");
            die;
        }
        $message = array();
        $mainmessage = array();
        foreach($temp as $value){
            $mainmessage['goods_id']    = $value['goods_id'];
            $mainmessage['goods_name']  = $value['goods_name'];
            $mainmessage['g_type']      = $value['g_type'];
            $mainmessage['g_class']     = $value['g_class'];
            $mainmessage['goods_image'] = $value['goods_image'];

            $message[] = array($value['type_name'],
                               trim($value['message_val']) == null ?
                               '暂无信息' : $value['message_val'],
                               'count'=>strlen($value['message_val'])
                               );
        }
        //取需要排序的列
        foreach ($message as $key => $row) {
            $volume[$key]  = $row['count'];
        }
        // 根据上面取出的列进行排序
        array_multisort($volume,SORT_ASC,$message);
    }
    ob_start();
?>

<!DOCTYPE HTML>
<html>
 <head>
  <title> <?php echo $mainmessage['g_class'] . ' '. $mainmessage['g_type'].' '.$mainmessage['goods_name']; ?> 爱遥控 - 在线电视机遥控器型号对照查询 </title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Designer" content="iyaok.com">
<meta name="keyword" content="<?php echo $mainmessage['g_class'] . ' '. $mainmessage['g_type'].' '.$mainmessage['goods_name']; ?> 爱遥控 遥控器大全 遥控器查询 搜索遥控器 空调遥控器 彩电遥控器 遥控器对照表 国外彩电遥控器 国内彩电遥控器 yaokongqi 万能遥控器" />
 <meta name="description" content=" 爱遥控为广大网友提供更方便的遥控器查询系统，一站式遥控器信息服务,遥控器,机顶盒遥控器,学习型遥控器,单功能遥控器,空调遥控器,电视机遥控器,RF-射频遥控器,下载型遥控器,普通遥控器，永久免费查询。" />
  <link rel="stylesheet" type="text/css" href="/css/in.css" />
  <!--[if gte IE 7]><link rel="stylesheet" type="text/css" href="/css/show-ie7.css" /><![endif]--> 
  <!--[if gte IE 8]><link rel="stylesheet" type="text/css" href="/css/show-ie8.css" /><![endif]-->
  <!--[if !IE]><!--><link rel="stylesheet" type="text/css" href="/css/show.css" /><!--<![endif]--> 
  

 </head>
<!--内容开始-->
 <body>
<div id="bodys">
        <div id="topmany">
                <div id="top"><a href="."><div id="logo"></div></a></div>
                        <div id="left">
                                <form id="myform"  action="search.php" method="get">
                                <div>
                                     <div onmouseover="this.style.display='none'" style="width:330px;position:absolute;z-index:2;line-height:25px;height:25px;float:left;background:#666666;color:#FFFFFF;margin-top:10px;margin-left:5px;">请输入彩电型号或者遥控器型号...</div>
                                </div>
                                <div id="edlin"><input id="edlintext" name="w" type="text" maxlength="30" size="30" value="" /></div>

                                </form>
                                <div id="select" onclick="search()">Search</div>
                        </div>
                <div id="among">
                        <div id="imagediv">
                            <div id="image">
                                <img alt="<?php echo $mainmessage['goods_name']; ?>" src="/images/goods/<?php echo $mainmessage['goods_image']; ?>">
                            </div>                          
                        </div>
                        <div id="messagediv">
                                <div id="titlediv"><?php echo $mainmessage['g_class'] . ' '. $mainmessage['g_type'].' '.$mainmessage['goods_name']; ?>
									<a href="./augment.php?id=<?php echo $goods_id; ?>">✎我要补充</a>
                                </div>
                                <!-- <div id="hr"></div> -->

                                <div id="message">
                                        <?php foreach($message as $val){ ?>
                                        <div class="text">
                                                <div class="text-left">
                                                <?php echo $val[0]; ?>
                                                ：</div>
                                                <div class="text-right">
                                                <?php echo $val[1]; ?>
                                                </div>
                                        </div>
                                        <?php } ?>
                                </div>

<!-- Baidu Button BEGIN -->
<div style="float:right;width:485px;" id="bdshare" class="bdshare_t bds_tools_32 get-codes-bdshare" >
<a class="bds_taobao"></a>
<a class="bds_tqq"></a>
<a class="bds_bdhome"></a>
<a class="bds_tieba"></a>
<a class="bds_kaixin001"></a>
<a class="bds_renren"></a>
<a class="bds_tsina"></a>
<a class="bds_qzone"></a>
<a class="bds_t163"></a>
<a class="bds_mshare"></a>
<span class="bds_more"></span>
<a class="shareCount"></a>
</div>
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1287781" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->

                        </div>
                </div>
        </div>
                <div id="about">
                本站数据来源于网络我们不能保证内容的正确性,通过使用本站内容随之而来的风险与本站无关。本站对非营利性内容产生的任何法律问题及风险不承担任何责任。如果您愿意帮助我们发展为更多的人提供帮助您也可以向我们的数据库<a href="/add.php">添加内容</a>, 当使用本站时，代表您已接受了本站的<a href="/about.php">使用条款</a>和<a href="/about.php">隐私条款</a>。 <a href="http://www.miibeian.gov.cn/">赣ICP备13006249</a> 版权所有，保留一切权利。
                </div>
</div>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?6668e0a07b0b9f2d8464728cf2d59d33";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="/js/select.js"></script>
 </body><!--内容结束-->
</html>

<?php 

file_put_contents($file,ob_get_contents());
ob_end_flush();

?>